//
//  DYJDateListViewController.m
//  Piece
//
//  Created by dllo on 16/6/11.
//  Copyright © 2016年 Northeast Dianli University. All rights reserved.
//

#import "DYJDateListViewController.h"
#import "TYTabButtonPagerController.h"
#import "DYJDateListContentViewController.h"
@interface DYJDateListViewController ()<TYPagerControllerDataSource>
@property (nonatomic, strong) TYTabButtonPagerController *pagerController;
@end

@implementation DYJDateListViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addPagerController];
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:nil action:nil];
}
- (void)addPagerController
{
    TYTabButtonPagerController *pagerController = [[TYTabButtonPagerController alloc]init];
    pagerController.dataSource = self;
    pagerController.adjustStatusBarHeight = YES;
    //TYTabButtonPagerController set barstyle will reset (TYTabPagerController not reset)cell propertys
    pagerController.barStyle = _variable ? TYPagerBarStyleProgressBounceView: TYPagerBarStyleProgressView;
    // after set barstyle,you need set cell propertys that you want
    pagerController.normalTextColor =[UIColor colorWithRed:0.76 green:0.79 blue:0.83 alpha:1.00];
    pagerController.selectedTextColor = [UIColor colorWithRed:0.76 green:0.79 blue:0.83 alpha:1.00];
    pagerController.normalTextFont = [UIFont systemFontOfSize:12];
    pagerController.selectedTextFont = [UIFont systemFontOfSize:12.5];
    pagerController.cellWidth = ScreenWidth / 3.0;
    
    pagerController.progressColor = [UIColor colorWithRed:0.59 green:0.72 blue:0.86 alpha:1.00];
        pagerController.progressWidth = 25;
    [self addChildViewController:pagerController];
    [self.view addSubview:pagerController.view];
    _pagerController = pagerController;
}

- (void)scrollToRamdomIndex
{
    [_pagerController moveToControllerAtIndex:arc4random() % 3 animated:NO];
}

- (NSInteger)numberOfControllersInPagerController
{
    return 3;
}


- (NSString *)pagerController:(TYPagerController *)pagerController titleForIndex:(NSInteger)index
{
    if (index == 0) { return @"短篇";}
    else if (index == 1) {return @"连载";}
    else  {return @"问题";}
}

- (UIViewController *)pagerController:(TYPagerController *)pagerController controllerForIndex:(NSInteger)index
{
    DYJDateListContentViewController *dlcvc = [[DYJDateListContentViewController alloc] init];
    dlcvc.pageIndex = (long)self.pagerController.curIndex;

    return dlcvc;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
